#!/bin/bash
# -*- coding: utf-8 -*-


user_list = [
    ("zhangkai", 123),
    ("likai", 123)
]


# count = 3
# while count > 0:
#     user = input('user: ').strip()
#     pwd = int(input('pwd: ').strip())  # 要注意，只有输入的是整数才能int强转
#     for i in user_list:
#         if user == i[0] and pwd == i[-1]:
#             # print('登录成功')
#             # count = 0
#             # break
#             exit('登录成功')
#     else:
#         count -= 1
#         if count == 0:
#             print('登录失败，你没有机会了')
#         else:
#             print('登录失败，你还有[{}]次尝试机会'.format(count))


# count = 3
# while count > 0:
#     user = input('user: ').strip()
#     pwd = int(input('pwd: ').strip())  # 要注意，只有输入的是整数才能int强转
#     for u, p in user_list:
#         # u, p = i
#         # print(11111, i, u, p)
#         if user == u and pwd == p:
#             exit('登录成功')
#     else:
#         count -= 1
#         if count == 0:
#             print('登录失败，你没有机会了')
#         else:
#             print('登录失败，你还有[{}]次尝试机会'.format(count))

# for i in range(5):
#     print(1111, i)
#     if i == 2:
#         break
# else:
#     print('2222')



# count = 3
# while count > 0:
#     user = input('user: ').strip()
#     pwd = int(input('pwd: ').strip())  # 要注意，只有输入的是整数才能int强转
#     for u, p in user_dict.items():
#         # u, p = i
#         # print(11111, i, u, p)
#         if user == u and pwd == p:
#             exit('登录成功')
#     else:
#         count -= 1
#         if count == 0:
#             print('登录失败，你没有机会了')
#         else:
#             print('登录失败，你还有[{}]次尝试机会'.format(count))

user_dict = {
    "zhangkai": 123,
    "likai": 123
}

count = 3
while count > 0:
    user = input('user: ').strip()
    pwd = int(input('pwd: ').strip())  # 要注意，只有输入的是整数才能int强转
    if pwd == user_dict.get(user, None) and user in user_dict:
        print('登录成功')
        break
    else:
        count -= 1
        if count == 0:
            print('登录失败，你没有机会了')
        else:
            print('登录失败，你还有[{}]次尝试机会'.format(count))













